/**
 */
package Entityrelationship.entityrelationship.impl;

import Entityrelationship.entityrelationship.EntityrelationshipPackage;
import Entityrelationship.entityrelationship.Relationship;
import Entityrelationship.entityrelationship.Relationships_Restriction;
import Entityrelationship.entityrelationship.TypeRestriction;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Relationships Restriction</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link Entityrelationship.entityrelationship.impl.Relationships_RestrictionImpl#getType_restriction <em>Type restriction</em>}</li>
 *   <li>{@link Entityrelationship.entityrelationship.impl.Relationships_RestrictionImpl#getRelationships <em>Relationships</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class Relationships_RestrictionImpl extends RSR_InclusionImpl implements Relationships_Restriction {
	/**
	 * The default value of the '{@link #getType_restriction() <em>Type restriction</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType_restriction()
	 * @generated
	 * @ordered
	 */
	protected static final TypeRestriction TYPE_RESTRICTION_EDEFAULT = TypeRestriction.EXCLUSION;

	/**
	 * The cached value of the '{@link #getType_restriction() <em>Type restriction</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType_restriction()
	 * @generated
	 * @ordered
	 */
	protected TypeRestriction type_restriction = TYPE_RESTRICTION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getRelationships() <em>Relationships</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRelationships()
	 * @generated
	 * @ordered
	 */
	protected EList<Relationship> relationships;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Relationships_RestrictionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return EntityrelationshipPackage.Literals.RELATIONSHIPS_RESTRICTION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TypeRestriction getType_restriction() {
		return type_restriction;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType_restriction(TypeRestriction newType_restriction) {
		TypeRestriction oldType_restriction = type_restriction;
		type_restriction = newType_restriction == null ? TYPE_RESTRICTION_EDEFAULT : newType_restriction;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__TYPE_RESTRICTION, oldType_restriction, type_restriction));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Relationship> getRelationships() {
		if (relationships == null) {
			relationships = new EObjectResolvingEList<Relationship>(Relationship.class, this, EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__RELATIONSHIPS);
		}
		return relationships;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__TYPE_RESTRICTION:
				return getType_restriction();
			case EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__RELATIONSHIPS:
				return getRelationships();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__TYPE_RESTRICTION:
				setType_restriction((TypeRestriction)newValue);
				return;
			case EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__RELATIONSHIPS:
				getRelationships().clear();
				getRelationships().addAll((Collection<? extends Relationship>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__TYPE_RESTRICTION:
				setType_restriction(TYPE_RESTRICTION_EDEFAULT);
				return;
			case EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__RELATIONSHIPS:
				getRelationships().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__TYPE_RESTRICTION:
				return type_restriction != TYPE_RESTRICTION_EDEFAULT;
			case EntityrelationshipPackage.RELATIONSHIPS_RESTRICTION__RELATIONSHIPS:
				return relationships != null && !relationships.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (type_restriction: ");
		result.append(type_restriction);
		result.append(')');
		return result.toString();
	}

} //Relationships_RestrictionImpl
